import {get, post} from "./axios";

//根据公司搜，暂不使用
export function searchForm(query) {
  return get('https://www.kanzhun.com/search/autoComplete.json', {
    params: {
      query: query
    }
  })
}

export class Article {
  constructor(article) {
    this.id = article._id
    this.title = article.title
    this.firm = article.baseInfo.firm
    this.position = article.baseInfo.position
    this.publishTime = article.publishTime
    this.processDesc = article.interview.detail[0].processDesc
    this.interviewTypes = []
    for(let item of article.interview.detail) {
      this.interviewTypes.push(item.interviewType)
    }
    this.feedback = article.feedback
  }
}

//获取面经列表，无query
export function getArticleList() {
  return get('/article/list')
}

//获取面经列表，带query
export function getArticleListWithQuery(city, time, position) {
  return get('/article/list', {
    params: {
      city: city,
      time: time,
      position: position
    }
  })
}

// 获取公司列表
export function getCompanyList() {
  return get('/article/companyList')
}

// 获取公司列表，有参数
export function getCompanyListWithQuery(city, time, firm) {
  return get('/article/company', {
    params: {
      city: city,
      time: time,
      firm: firm
    }
  })
}

// 获取特定公司面经列表
export function getFirmArticle(firm) {
  return get('/article/singleCompanyList', {
    params: {
      firm: firm
    }
  })
}

// 获取题库列表
export function getQuestionList(base) {
  return get('/queBank/list', {
    params: {
      base: base
    }
  })
}

// 获取题库详情页
export function getQuestionDetail(questionId) {
  return get('/queBank/detail/' + questionId)
}

// 获取公司职位
export function getFirmPosition(firm) {
  return get('/article/position', {
    params: {
      firm: firm
    }
  })
}

// 根据公司职位，搜索面经
export function getArticleByPost(firm, position) {
  return get('/article/singleCompanySearch', {
    params: {
      firm: firm,
      position: position
    }
  })
}



